﻿<UserControl xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:sv="clr-namespace:Schedulr.Views"
             xmlns:svc="clr-namespace:Schedulr.Views.Controls"
             x:Class="Schedulr.Views.QueuedPicturesEditor"
             d:DesignHeight="300"
             d:DesignWidth="300"
             mc:Ignorable="d" 
             DataContext="{Binding Path=QueuedPicturesViewModel, Source={StaticResource Locator}}">
    <Grid>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="*" />
            <ColumnDefinition Width="Auto" />
            <ColumnDefinition Width="*" x:Name="detailsColumn" />
        </Grid.ColumnDefinitions>

        <GridSplitter Grid.Column="1" ResizeDirection="Columns" Width="5" HorizontalAlignment="Stretch" Background="{DynamicResource MainBackgroundBrush}" IsEnabled="{Binding Path=PictureDetails.DetailsPanelVisible, FallbackValue=False}" />

        <Border Grid.Column="0" Style="{DynamicResource BorderStyle}" Background="{DynamicResource DiagramGradientBrush}">
            <svc:PictureQueue DataContext="{Binding PictureQueue}" />
        </Border>

        <Border Style="{DynamicResource BorderStyle}" Background="{DynamicResource DiagramGradientBrush}" Grid.Column="2" Visibility="{Binding Path=PictureDetails.DetailsPanelVisibility, FallbackValue=Collapsed}">
            <svc:PictureDetails DataContext="{Binding PictureDetails}" />
        </Border>

    </Grid>
    <!-- Make sure to place the style at the bottom because the trigger depends on the detailsColumn defined above. -->
    <UserControl.Style>
        <Style TargetType="sv:QueuedPicturesEditor" BasedOn="{StaticResource {x:Type UserControl}}">
            <Style.Triggers>
                <DataTrigger Binding="{Binding Path=PictureDetails.DetailsPanelVisibility, FallbackValue=Collapsed}" Value="Collapsed">
                    <Setter Property="DetailsPanelVisibility" Value="Collapsed" />
                </DataTrigger>
            </Style.Triggers>
        </Style>
    </UserControl.Style>
</UserControl>